home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_02_06
/
2n06076b
< prev
next >
Wrap
Text File
|
1991-04-14
|
561b
|
23 lines
double setsigdig(double x, unsigned int n)
{
double shift, result;
if ((n == 0U) || (n > DBL_DIG))
result = x;
else
{
// adjust the number of significant digits
--n;
// calculate the number of digits to be shifted
shift = pow(10.0,(double)n
- floor(log10(fabs(x))));
result = tonearest(x * shift) / shift;
}
return result;
}